#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int MAXN = 9;
int clocks[MAXN] = {0}, step[MAXN] = {0};

void check(int x,int y,int z){
	int AA = (4 - ((x + y + clocks[0]) % 4)) % 4;//A
	int BB = (4 - ((x + y + z + clocks[1]) % 4)) % 4;//B
	int CC = (4 - ((y + z + clocks[2]) % 4)) % 4;//C
	int DD = (4 - ((x + AA + BB + clocks[3]) % 4)) % 4;//D
	int EE = (4 - ((x + z + BB + DD + clocks[4]) % 4)) % 4;//E
	int II = (4 - ((CC + EE + clocks[8]) % 4)) % 4;//I
	//F,G,H
	//通过后三个来验证要求
	if (//满足题目要求，全为12点
		(clocks[5] + z + BB + CC + EE) % 4 == 0 &&//F
		(clocks[6] + AA + DD + II) % 4 == 0 &&//G
		(clocks[7] + BB + DD + II + EE) % 4 == 0//H
		) {
		
		int tmp[9] = { x,y,z,AA,BB,CC,DD,II,EE };
		int sum = 0, ans = 0;
		for (int i = 0; i < 9; ++i)
			sum += tmp[i], ans += step[i];
		
		if (sum < ans)//取总的路径数最小的
			memcpy(step, tmp, sizeof(step));
	}
}
void find(){
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				check(i,j,k);
			}
		}
	}
}

signed main()
{
	for (int i = 0; i < 9; i++) {
		cin >> clocks[i], step[i] = 4;// 输入并给定较大值
	}
	find();// 执行枚举
	
	// 输出结果
	for (int i = 0; i < 9; i++) {
		while (step[i] --) {
			cout << i + 1 << ' ';
		}
	}
	return 0;
//3 3 0 
//2 2 2 
//2 1 2
//
//0 3 0
//3 2 2 
//3 1 2
//
//0 0 0 
//0 3 3
//3 2 2
//
//0 0 0 
//0 3 3 
//0 3 3
//
//0 0 0
//0 0 0 
//0 0 0

}
